﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SimpleActionNoException.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   Defines the SimpleActionNoException type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Collaboris.Saf.Tests.Support.Actions
{
    using System;

    using Engine;
    using Entities;

    public class ActionToCreateDynamicProperty : ActionBase<StringList>
    {
      
        private int newAge = 10;

        public ActionToCreateDynamicProperty()
        {
        }

        public ActionToCreateDynamicProperty(Guid id) : base(id)
        {
        }

        public int NewAge
        {
            get
            {
                return newAge;
            }
            set
            {
                newAge = value;
            }
        }

        protected override ProcessStatus DoAction(SafContext context, StringList entity)
        {
            Person savedPerson = new Person();
            savedPerson.Age = 12;
            savedPerson.Forename = "Bart";
            savedPerson.Surname = "Sympson";
            
            context.ActionProperties.Add("DynamicName", "New Mark Jones", true);
            context.ActionProperties.Add("DynamicSurname", "New Surname", true);
            context.ActionProperties.Add("DynamicAge", 40, true);
            context.ActionProperties.Add("PersonInfo", savedPerson);
            this.NewAge = 41;

            return ProcessStatus.Success;
        }

        protected override ProcessStatus UndoAction(SafContext context, StringList entity)
        {
         
            return ProcessStatus.Success;
        }
    }
}